#include <cstdio>
#include <cctype>

#define MAX_S 10
#define MAX_DIGITS 8
#define DECIMAL_DIGITS 10
#define HSEG '-'
#define VSEG '|'
#define SPACE ' '

enum LCD
{
	UP,
	MIDDLE,
	BOTTOM,
	LEFT_UP,
	LEFT_BOTTOM,
	RIGHT_UP,
	RIGHT_BOTTOM,
	//-----------
	MAX_LCD
};

enum REGION
{
	OVER,
	UP_SIDES,
	CENTER,
	DOWN_SIDES,
	DOWN
};


int digit_lcd[DECIMAL_DIGITS][MAX_LCD] = {
	{ HSEG, SPACE,  HSEG,  VSEG,  VSEG,  VSEG,  VSEG},	// 0
	{SPACE, SPACE, SPACE, SPACE, SPACE,  VSEG,  VSEG},	// 1
	{ HSEG,  HSEG,  HSEG, SPACE,  VSEG,  VSEG, SPACE},	// 2
	{ HSEG,  HSEG,  HSEG, SPACE, SPACE,  VSEG,  VSEG},	// 3
	{SPACE,  HSEG, SPACE,  VSEG, SPACE,  VSEG,  VSEG},	// 4
	{ HSEG,  HSEG,  HSEG,  VSEG, SPACE, SPACE,  VSEG},	// 5
	{ HSEG,  HSEG,  HSEG,  VSEG,  VSEG, SPACE,  VSEG},	// 6
	{ HSEG, SPACE, SPACE, SPACE, SPACE,  VSEG,  VSEG},	// 7
	{ HSEG,  HSEG,  HSEG,  VSEG,  VSEG,  VSEG,  VSEG},	// 8
	{ HSEG,  HSEG,  HSEG,  VSEG, SPACE,  VSEG,  VSEG}	// 9
};


void print_line (int digit, int size, REGION region)
{
	int c1, c2;

	switch (region)
	{
		case OVER:
			c1 = digit_lcd[digit][UP];
			break;
		case UP_SIDES:
			c1 = digit_lcd[digit][LEFT_UP];
			c2 = digit_lcd[digit][RIGHT_UP];
			break;
		case CENTER:
			c1 = digit_lcd[digit][MIDDLE];
			break;
		case DOWN_SIDES:
			c1 = digit_lcd[digit][LEFT_BOTTOM];
			c2 = digit_lcd[digit][RIGHT_BOTTOM];
			break;
		case DOWN:
			c1 = digit_lcd[digit][BOTTOM];
			break;
	}

	switch (region)
	{
		case OVER:
		case CENTER:
		case DOWN:
			putchar (SPACE);
			while (--size >= 0)
				putchar (c1);
			putchar (SPACE);
			break;
		case UP_SIDES:
		case DOWN_SIDES:
			putchar (c1);
			while (--size >= 0)
				putchar (SPACE);
			putchar (c2);
			break;
	}
}


int main ()
{
	int s, digit[MAX_DIGITS], c, n;

	while (scanf("%d ", &s), s != 0)
	{
		for (n = 0; c = getchar (), isdigit (c); ++n)
		{
			digit[n] = c - '0';
		}

		for (int i = 0; i < n; ++i)
		{
			print_line (digit[i], s, OVER);
			if (i < n - 1)
				putchar (SPACE);
		}
		putchar ('\n');

		for (int t = 0; t < s; ++t)
		{
			for (int i = 0; i < n; ++i)
			{
				print_line (digit[i], s, UP_SIDES);
				if (i < n - 1)
					putchar (SPACE);
			}
			putchar ('\n');
		}

		for (int i = 0; i < n; ++i)
		{
			print_line (digit[i], s, CENTER);
			if (i < n - 1)
				putchar (SPACE);
		}
		putchar ('\n');

		for (int t = 0; t < s; ++t)
		{
			for (int i = 0; i < n; ++i)
			{
				print_line (digit[i], s, DOWN_SIDES);
				if (i < n - 1)
					putchar (SPACE);
			}
			putchar ('\n');
		}

		for (int i = 0; i < n; ++i)
		{
			print_line (digit[i], s, DOWN);
			if (i < n - 1)
				putchar (SPACE);
		}
		putchar ('\n');
		putchar ('\n');
	}
}